<template>
  <el-dropdown trigger="click" @command="changeLanguage">
    <!-- 显示一个图标 -->
    <div>
      <svg-icon icon-class="language" style="color:#fff;font-size:20px" />
    </div>
    <!-- 下拉菜单 -->
    <el-dropdown-menu slot="dropdown">
      <el-dropdown-item :disabled="this.$i18n.locale==='zh'" command="zh">中文</el-dropdown-item>
      <el-dropdown-item :disabled="this.$i18n.locale==='en'" command="en">英文</el-dropdown-item>
    </el-dropdown-menu>
  </el-dropdown>
</template>

<script>
import Cookie from 'js-cookie'

export default {
	methods: {
		changeLanguage(type) {
      Cookie.set('language', type) // 切换多语言
      this.$i18n.locale = type // 设置给本地的i18n插件
      this.$message.success('切换多语言成功')
		}
	}
}
</script>

<style>

</style>